package com.hazmatt.android.controller;

public enum PololuCommand
{
	SIGNATURE         ( (byte)0x81, 6 ),
	RAW_SENSORS       ( (byte)0x86, 10 ),
	CALIBRATED_SENSORS( (byte)0x87, 10 ),
	TRIMPOT           ( (byte)0xB0, 2 ),
	BATTERY_MILLIVOLTS( (byte)0xB1, 2 ),
	PLAY_MUSIC        ( (byte)0xB3, 0 ),
	CALIBRATE         ( (byte)0xB4, 0 ),
	RESET_CALIBRATION ( (byte)0xB5, 0 ),
	LINE_POSITION     ( (byte)0xB6, 2 ),
	CLEAR_LCD         ( (byte)0xB7, 0 ),
	PRINT             ( (byte)0xB8, 0 ),
	LCD_GOTO_XY       ( (byte)0xB9, 0 ),
	AUTOCALIBRATE     ( (byte)0xBA, 1 ),
	START_PID         ( (byte)0xBB, 0 ),
	STOP_PID          ( (byte)0xBC, 0 ),
	M1_FORWARD        ( (byte)0xC1, 0 ),
	M1_BACKWARD       ( (byte)0xC2, 0 ),
	M2_FORWARD        ( (byte)0xC5, 0 ),
	M2_BACKWARD       ( (byte)0xC6, 0 ),
	M1_M2_FORWARD     ( (byte)0xC7, 0 ),
	M1_M2_BACKWARD    ( (byte)0xC8, 0 ),
	IR_VALUES         ( (byte)0xB1, 2 );
	//IR_VALUES         ( (byte)0xD1, 6 );
	
	private byte commandByte;
	private int responseBytes;
	
	private PololuCommand( byte commandByte, int responseBytes )
	{
		this.commandByte = commandByte;
		this.responseBytes = responseBytes;
	}

	public byte getCommandByte()
	{
		return commandByte;
	}

	public int getResponseBytes()
	{
		return responseBytes;
	}
	
	public static PololuCommand findByCommandByte( byte commandByte ) {
		for ( PololuCommand command : PololuCommand.values() ) {
			if ( command.getCommandByte() == commandByte ) {
				return command;
			}
		}
		return null;
	}
}
